from django import template
from feedbag.apps.social.models import TwitterTweet

register = template.Library()

@register.inclusion_tag('twitter.html', takes_context=True)
def twitter(context, limit=10):
	tweets = []
	try:
		tweets = TwitterTweet.objects.all().order_by('-created')[:limit]
	except:
		pass
	
	return {
		'tweets': tweets,
		'request': context['request'],
		'settings': context['settings'],
	}


